package com.neutech.neupha.service.Impl;

import java.util.List;
import java.util.Map;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.neutech.neupha.mapper.ConstantNameMapper;
import com.neutech.neupha.mapper.DrugMapper;
import com.neutech.neupha.mapper.PhaMapper;
import com.neutech.neupha.service.PhaService;
import com.neutech.neupha.vo.ToAddUserVo;
import com.neutech.neupha.vo.ViewDate;
import com.neutech.po.ConstantName;

import com.neutech.po.Doctor;
import com.neutech.po.Drug;
import com.neutech.po.Neupha;


@Service
public class PhaServiceImpl implements PhaService{
   
    
    @Autowired
    private DrugMapper drugMapper;	
	@Override
	public ViewDate getDrugs(Map<String, Object> map) {
		// TODO Auto-generated method stub
		String pageNumber = (String)map.get("pageNumber");
		try {
			Integer pn = new Integer(pageNumber);
			pn = pn - 1;
			
			if(pn<0) {
				pn = 0;
			};
			pn = pn * 10;
			map.put("pageNumber", pn);
			}catch(Exception e) {
				map.put("pageNumber", 0);
			}
		ViewDate vd = new ViewDate();
		vd.setMap(drugMapper.getDrugs(map));
		vd.setPageNumber(drugMapper.getDrugsCount(map));
		return vd;
	}
	@Override
	public int addNewDrug(Map<String, Object> drug) {
		// TODO Auto-generated method stub
		return drugMapper.addNewDrug(drug);
	}
	@Override
	public int delDrug(int id) {
		// TODO Auto-generated method stub
		return drugMapper.delDrug(id);
	}
	@Override
	public int updateDrug(Drug drug) {
		// TODO Auto-generated method stub
		return drugMapper.updateDrug(drug);
	}


	

	

	

	
}
